//
//  ZQloginRegisterViewController.m
//  BuDeJie
//
//  Created by 仲琦 on 16/4/6.
//  Copyright © 2016年 仲琦. All rights reserved.
//

#import "ZQloginRegisterViewController.h"
#import "ZQLoginRegisterView.h"
#import "ZQFastLoginView.h"
@interface ZQloginRegisterViewController ()
@property (weak, nonatomic) IBOutlet UIView *loginRegisterView;
@property (weak, nonatomic) IBOutlet UIView *FastLoginView;

//约束属性
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *moveLoginRegister;

@end

@implementation ZQloginRegisterViewController

//关闭按钮
- (IBAction)close:(id)sender {
    
    [self dismissViewControllerAnimated:YES completion:nil];
}

//注册账号按钮
- (IBAction)registerBtnClick:(UIButton *)button {
    button.selected = !button.selected;
    
    //三目运算符  判断约束是否等于0
    self.moveLoginRegister.constant = self.moveLoginRegister.constant == 0 ? -ZQScreenW : 0;
    
    //动画效果刷新view
    [UIView animateWithDuration:0.5 animations:^{
        [self.view layoutIfNeeded];
    }];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //添加view
    
    ZQLoginRegisterView *loginView = [ZQLoginRegisterView loginView];
    [self.loginRegisterView addSubview:loginView];
    
    ZQLoginRegisterView *registerView = [ZQLoginRegisterView registerView];
    [self.loginRegisterView addSubview:registerView];
    
    ZQFastLoginView *flV = [ZQFastLoginView fastLoginView];
    [self.FastLoginView addSubview:flV];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


//设置完约束后调用
- (void)viewDidLayoutSubviews
{
    [super viewDidLayoutSubviews];
    
    //取出view 设置frame
    
    ZQLoginRegisterView *loginView = self.loginRegisterView.subviews[0];
    loginView.frame = CGRectMake(0, 0, self.loginRegisterView.zq_width * 0.5, self.loginRegisterView.zq_height);
    
    ZQLoginRegisterView *registerView = self.loginRegisterView.subviews[1];
    registerView.frame = CGRectMake(self.loginRegisterView.zq_width * 0.5, 0, self.loginRegisterView.frame.size.width * 0.5, self.loginRegisterView.zq_height);

    ZQFastLoginView *flV = self.FastLoginView.subviews[0];
    flV.frame = self.FastLoginView.bounds;
    
    
    
}
@end
